home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / util / gdostool / part01
Encoding:
Internet Message Format  |  1990-10-14  |  12.7 KB

  1. Path: abcfd20.larc.nasa.gov!amiga-request
  2. From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v90i278: GDosTool - test/set memory location 0, Part01/01
  4. Reply-To: "John Davis,chem dept, UoC NZ" <CHEM194@canterbury.ac.nz>
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v90i278@abcfd20.larc.nasa.gov>
  7. Date: 14 Oct 90 18:19:25 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga
  11.  
  12. Submitted-by: "John Davis,chem dept, UoC NZ" <CHEM194@canterbury.ac.nz>
  13. Posting-number: Volume 90, Issue 278
  14. Archive-name: util/gdostool/part01
  15.  
  16. [ uuencoded executable and icons enclosed  ...tad ]
  17.  
  18. A tiny utility that will tell you (via a requester) whether memory
  19. location 0 is set to a non-zero value, and give you an option to
  20. either clear it, or set it to a 'problem' value. The first option
  21. is handy for people with 2091s and A590s, which have been known
  22. to set $0="GDOS", the facility to set $0='GDOS' is handy for 
  23. software authors wishing to make sure their programs aren't
  24. accidentally (either thru nil pointers or dropped #'s in assembler)
  25. using $0 as a pointer.
  26.  
  27. #!/bin/sh
  28. # This is a shell archive.  Remove anything before this line, then unpack
  29. # it by saving it into a file and typing "sh file".  To overwrite existing
  30. # files, type "sh file -c".  You can also feed this as standard input via
  31. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  32. # will see the following message at the end:
  33. #        "End of archive 1 (of 1)."
  34. # Contents:  gdostool.doc gdostool.s gdostool.s.uu gdostool.uu
  35. #   gdostool0.uu gdostool1.uu
  36. # Wrapped by tadguy@abcfd20 on Sun Oct 14 14:19:23 1990
  37. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  38. if test -f 'gdostool.doc' -a "${1}" != "-c" ; then 
  39.   echo shar: Will not clobber existing file \"'gdostool.doc'\"
  40. else
  41. echo shar: Extracting \"'gdostool.doc'\" \(1285 characters\)
  42. sed "s/^X//" >'gdostool.doc' <<'END_OF_FILE'
  43. XGdosTool - By J Davis 08/1990
  44. X
  45. XWhy
  46. X---
  47. X
  48. XAn  easy  mistake  to make when progrmming in assembler is to accidentally
  49. Xuse  $0 (the value in memory location $0) where you mean #$0 (the constant
  50. Xvalue  zero).   A  subtle  mistake - one not aided by the fact that memory
  51. Xloaction  0  often holds 0, so it will yield the right results.  
  52. X
  53. XThe first you notice of this problem is when your code is run on some a590
  54. Xequipped  500's  ,  or  2000s with 2091 controllers, where $0 may actually
  55. Xhold  the  string  'GDOS'.  The same situation can also occur in most high
  56. Xlevel languages, by de-referencing a NIL pointer.
  57. X
  58. XThe  result  can  be anything from small errors upto a full blown GURU (if
  59. Xthe  code  tries  to  de-ref  $0  as a pointer to a word - it will yield a
  60. Xnon-word aligned word access)
  61. XThis is a common problem (other programs that have trouble with a non zero
  62. Xlocation  0  are  virusx4,  lharc1.20,  execellence  1.11,  Jrcomm 1.0 and
  63. Xseveral others).
  64. XBy  using  this tool you can set location zero to a 'problem' value before
  65. Xtesting  your code - this will hopefully make the release of programs with
  66. Xsuch 'mistakes' less common.
  67. XYou  can  also  set  it  back  to  $0000000 - useful after you've finished
  68. Xtesting, and also potentially useful for people with a590s or 2091s.
  69. X
  70. END_OF_FILE
  71. if test 1285 -ne `wc -c <'gdostool.doc'`; then
  72.     echo shar: \"'gdostool.doc'\" unpacked with wrong size!
  73. fi
  74. # end of 'gdostool.doc'
  75. fi
  76. if test -f 'gdostool.s' -a "${1}" != "-c" ; then 
  77.   echo shar: Will not clobber existing file \"'gdostool.s'\"
  78. else
  79. echo shar: Extracting \"'gdostool.s'\" \(3694 characters\)
  80. sed "s/^X//" >'gdostool.s' <<'END_OF_FILE'
  81. X; program to allow user examination and setting of ($0)
  82. X; 
  83. X; allows both simulation of the $0='GDOS' phenomena on some a590s and
  84. X; 2091s ( useful for testing code for nil pointer de-references and
  85. X; incorrect use of $0 when it should be #$0
  86. X;
  87. X; also allows clearing of $0, either to remove settings from previous
  88. X; use, or due to the a590/2091 itself
  89. X
  90. Xforbid        equ    -$084    ; offsets for various exec and int calls
  91. Xgetmsg        equ    -$174    ; saves long includes and compile times
  92. Xreplymsg    equ    -$17a
  93. Xwaitport    equ    -$180
  94. Xfindtask    equ    -$126
  95. Xautoreq        equ    -$15c
  96. Xopenlib        equ    -$228
  97. Xcloselib    equ    -$19e
  98. X
  99. Xpr_cli        equ    $0Ac    ; process cli flag offset
  100. Xpr_msgport    equ    $05c    ; process msgport offset
  101. X
  102. Xstartup:    move.l    $4,a6
  103. X        move.l    #0,a1
  104. X        jsr    findtask(a6)        ; find ourselves
  105. X
  106. X        move.l    d0,a4            ; save our process pointer
  107. X
  108. X        move.l    pr_cli(a4),d0
  109. X        bne    fromdos            ; was a DOS startup
  110. X
  111. X        ; was started from WB
  112. X
  113. X        lea    pr_msgport(a4),a0
  114. X        jsr    waitport(a6)        ; wait for startup msg
  115. X        lea    pr_msgport(a4),a0
  116. X        jsr    getmsg(a6)        ; get the wb msg
  117. X
  118. X        move.l    d0,wbmsg        ; save pointer to our startup msg
  119. X        move.l    #1,wb            ; flag we started from wb
  120. X
  121. Xfromdos:    move.l    $0,d0
  122. X        cmp.l    #$0,d0
  123. X        beq    is_zero            ; if $0=0 then req already setup
  124. X
  125. X        lea    nzbodytext,a0
  126. X        move.l    a0,ctext        ; set so req displays non-zero msg
  127. X        bra    _xx
  128. X
  129. Xis_zero:    lea    zbodytext,a0
  130. X        move.l    a0,ctext
  131. X
  132. X_xx:        lea    intuiname,a1
  133. X        move.l    #0,d0
  134. X        move.l    $4,a6
  135. X        jsr    openlib(a6)         ; open intuition lib
  136. X
  137. X        move.l    d0,a6            ; save ibase
  138. X        
  139. X        move.l    #0,a0            ; window to display in
  140. X        move.l    #bodyitext,a1        ; body text
  141. X        move.l    #yesitext,a2         ; postive text
  142. X        move.l    #noitext,a3          ; negative text
  143. X        move.l    #0,d0            ; pflags
  144. X        move.l    #0,d1            ; nflags
  145. X        move.l    #640,d2            ; width
  146. X        move.l    #50,d3            ; height
  147. X        jsr    autoreq(a6)        ; request user confirmation
  148. X
  149. X        cmp.l    #0,d0
  150. X        beq    cleargdos        ; user selected clear
  151. X
  152. Xsetgdos:    move.l    #"GDOS",$0        ; set $0="GDOS"        
  153. X        bra    _n1
  154. X
  155. Xcleargdos:    move.l    #$0,$0
  156. X
  157. X_n1:        move.l    a6,a1            ; close intuition lib
  158. X        move.l    $4,a6
  159. X        jsr    closelib(A6)
  160. X        
  161. Xexit:        move.l    wb,d0
  162. X        cmp.l    #$0,d0            ; was this a CLI invocation
  163. X        beq    exit_dos
  164. X
  165. X        ; workbench exit
  166. X
  167. X        move.l    $4,a6
  168. X        jsr    forbid(a6)        ; lock out everyone else
  169. X
  170. X        move.l    wbmsg,a1
  171. X        jsr    replymsg(a6)        ; reply to Wbstartup msg
  172. X
  173. Xexit_dos:    move.l    #0,d0            ; return with return code 0
  174. X        rts            
  175. X
  176. X;=============================================================
  177. X        
  178. Xwb:        dc.l    0            ; run mode flag 0=dos process 1=wbprocess
  179. Xwbmsg:        dc.l    0            ; where we save our workbench msg
  180. X
  181. Xintuiname:    dc.b    "intuition.library",0
  182. X
  183. X; stuff for our autorequester
  184. X
  185. Xbodyitext:    dc.b    0           ; front pen
  186. X        dc.b    1           ; back pen
  187. X        dc.b    0           ; draw mode
  188. X        dc.w    0           ; leftedge
  189. X        dc.w    6           ; topedge
  190. X        dc.l    0           ; textattr = default
  191. X        dc.l    bodytext1      ; actual text
  192. X        dc.l    nbodyitext     ; next
  193. X
  194. Xnbodyitext:    dc.b    0           ; front pen
  195. X        dc.b    1           ; back pen
  196. X        dc.b    0           ; draw mode
  197. X        dc.w    0           ; leftedge
  198. X        dc.w    20           ; topedge
  199. X        dc.l    0           ; textattr = default
  200. Xctext:        dc.l    0          ; actual text
  201. X        dc.l    0         ; next
  202. X
  203. X
  204. Xyesitext:    dc.b    2        ; front pen
  205. X        dc.b    1        ; back pen
  206. X        dc.b    0        ; draw mode
  207. X        dc.w    4        ; leftedge
  208. X        dc.w    4        ; topedge
  209. X        dc.l    0        ; textattr = default
  210. X        dc.l    yestext        ; actual text
  211. X        dc.l    0        ; next
  212. X        
  213. Xnoitext:    dc.b    2        ; front pen
  214. X        dc.b    1        ; back pen
  215. X        dc.b    0        ; draw mode
  216. X        dc.w    4        ; leftedge
  217. X        dc.w    4        ; topedge
  218. X        dc.l    0        ; textattr = default
  219. X        dc.l    notext        ; actual text
  220. X        dc.l    0        ; next        
  221. X
  222. X        ; actual text for our requester
  223. X
  224. Xbodytext1:    dc.b    "   SetGDOS by J Davis, 08-1990 v1.0 - an aid to hunting nil pointer de-refs",0
  225. Xzbodytext:    dc.b    "                  Location $0 currently holds a NULL (0) value",0
  226. Xnzbodytext:    dc.b    "                     Location $0 is currently NON-ZERO",0
  227. X
  228. Xyestext:    dc.b    "Set $0='GDOS'",0
  229. Xnotext:        dc.b    "Set $0=NULL",0
  230. X
  231. X        END
  232. END_OF_FILE
  233. if test 3694 -ne `wc -c <'gdostool.s'`; then
  234.     echo shar: \"'gdostool.s'\" unpacked with wrong size!
  235. fi
  236. # end of 'gdostool.s'
  237. fi
  238. if test -f 'gdostool.s.uu' -a "${1}" != "-c" ; then 
  239.   echo shar: Will not clobber existing file \"'gdostool.s.uu'\"
  240. else
  241. echo shar: Extracting \"'gdostool.s.uu'\" \(538 characters\)
  242. sed "s/^X//" >'gdostool.s.uu' <<'END_OF_FILE'
  243. Xbegin 666 gdostool.s.info
  244. XMXQ```0```````````"``'``%``,``0#%\-@`````````````````````````&
  245. XM````!```QA]Z`,7OXH````"````````````````````````````@`!P``@#%\
  246. XM[_@#````````````!___^`?___@&$)(8!S.3.`<PQS@',Y,X!S"3.`?___@$G
  247. XM```(!___^`?_?[@'_O-X!_S-.`?Z,M@'_W^X!][S>`<DS3@/FC+8#WO]^`[WY
  248. XMF_@9)FGX'-&6^#____A____X#___^````````````````````````````>]MZ
  249. XMY@#,;,8`SSC&`,QLQ@#/;,8````&`___]@````8``(!&``$,A@`#,L8`!<TF_
  250. XM``"`1@`A#(8`VS+&`&7-+@"$`@X!"&0.!MF6'@,N:1X````^````_@____X#0
  251. XG___^``````````9C.F-E9``````(````#D9)3$5465!%/51E>'0`E
  252. X``
  253. Xend
  254. Xsize 354
  255. END_OF_FILE
  256. if test 538 -ne `wc -c <'gdostool.s.uu'`; then
  257.     echo shar: \"'gdostool.s.uu'\" unpacked with wrong size!
  258. fi
  259. # end of 'gdostool.s.uu'
  260. fi
  261. if test -f 'gdostool.uu' -a "${1}" != "-c" ; then 
  262.   echo shar: Will not clobber existing file \"'gdostool.uu'\"
  263. else
  264. echo shar: Extracting \"'gdostool.uu'\" \(1559 characters\)
  265. sed "s/^X//" >'gdostool.uu' <<'END_OF_FILE'
  266. Xbegin 666 gdostool
  267. XM```#\P`````````!``````````````"5```#Z0```)4L>0````0B?`````!.B
  268. XMKO[:*$`@+`"L9@``(D'L`%Q.KOZ`0>P`7$ZN_HPCP````1`C_`````$```$,A
  269. XM(#D`````L+P`````9P``$D'Y```"`2/(```!1F````Y!^0```<(CR````49#-
  270. XM^0```10@/``````L>0````1.KOW8+$`@?``````B?````28D?````4XF?```"
  271. XM`6(@/``````B/``````D/````H`F/````#).KOZDL+P`````9P``$"/\1T1/-
  272. XM4P````!@```,(_P``````````").+'D````$3J[^8B`Y```!#+"\`````&<`,
  273. XM`!8L>0````1.KO]\(GD```$03J[^AB`\`````$YU``````````!I;G1U:71I'
  274. XM;VXN;&EB<F%R>0```0``````!@````````%V```!.@`!```````4````````.
  275. XM`````````@$````$``0````````".``````"`0````0`!`````````)&````8
  276. XM`"`@(%-E=$=$3U,@8GD@2B!$879I<RP@,#@M,3DY,"!V,2XP("T@86X@86ED8
  277. XM('1O(&AU;G1I;F<@;FEL('!O:6YT97(@9&4M<F5F<P`@("`@("`@("`@("`@*
  278. XM("`@("!,;V-A=&EO;B`D,"!C=7)R96YT;'D@:&]L9',@82!.54Q,("@P*2!VB
  279. XM86QU90`@("`@("`@("`@("`@("`@("`@("!,;V-A=&EO;B`D,"!I<R!C=7)R,
  280. XM96YT;'D@3D].+5I%4D\`4V5T("0P/2='1$]3)P!3970@)#`]3E5,3```````4
  281. XM`^P````0`````````"P````V````3````%(```!<````8@```&@```"&````K
  282. XMC````)(```#B````_````3(```$V```!6@```6X````````#\`````%W8@``]
  283. XM```!#`````%?;C$`````U`````%?>'@`````9@````%E>&ET````X`````)C6
  284. XM=&5X=````````48````"=V)M<V<```````$0`````FYO=&5X=``````"1@``K
  285. XM``)F<F]M9&]S`````#H````":7-?>F5R;P````!:`````FYO:71E>'0````!;
  286. XM8@````)S971G9&]S`````+P````"<W1A<G1U<````````````GEE<W1E>'0`&
  287. XM```".`````)E>&ET7V1O<P```00````">65S:71E>'0```%.`````V)O9'EI*
  288. XM=&5X=````````28````#8F]D>71E>'0Q```````!=@````-C;&5A<F=D;W,`!
  289. XM``````#*`````VEN='5I;F%M90```````10````#>F)O9'ET97AT```````!=
  290. XMP@````-N8F]D>6ET97AT``````$Z`````VYZ8F]D>71E>'0``````@$`````K
  291. X$```#\@-NF
  292. X``
  293. Xend
  294. Xsize 1084
  295. END_OF_FILE
  296. if test 1559 -ne `wc -c <'gdostool.uu'`; then
  297.     echo shar: \"'gdostool.uu'\" unpacked with wrong size!
  298. fi
  299. # end of 'gdostool.uu'
  300. fi
  301. if test -f 'gdostool0.uu' -a "${1}" != "-c" ; then 
  302.   echo shar: Will not clobber existing file \"'gdostool0.uu'\"
  303. else
  304. echo shar: Extracting \"'gdostool0.uu'\" \(540 characters\)
  305. sed "s/^X//" >'gdostool0.uu' <<'END_OF_FILE'
  306. Xbegin 666 gdostool.doc.info
  307. XMXQ```0```````````"``'``%``,``0#%\-@`````````````````````````&
  308. XM````!```QA]Z`,7OXH````"````````````````````````````@`!P``@#%\
  309. XM[_@#````````````!___^`?___@&$)(8!S.3.`<PQS@',Y,X!S"3.`?___@$G
  310. XM```(!___^`?_?[@'_O-X!_S-.`?Z,M@'_W^X!][S>`<DS3@/FC+8#WO]^`[WY
  311. XMF_@9)FGX'-&6^#____A____X#___^````````````````````````````>]MZ
  312. XMY@#,;,8`SSC&`,QLQ@#/;,8````&`___]@````8``(!&``$,A@`#,L8`!<TF_
  313. XM``"`1@`A#(8`VS+&`&7-+@"$`@X!"&0.!MF6'@,N:1X````^````_@____X#0
  314. XG___^``````````9C.F-E9``````(````#D9)3$5465!%/51E>'0`E
  315. X``
  316. Xend
  317. Xsize 354
  318. END_OF_FILE
  319. if test 540 -ne `wc -c <'gdostool0.uu'`; then
  320.     echo shar: \"'gdostool0.uu'\" unpacked with wrong size!
  321. fi
  322. # end of 'gdostool0.uu'
  323. fi
  324. if test -f 'gdostool1.uu' -a "${1}" != "-c" ; then 
  325.   echo shar: Will not clobber existing file \"'gdostool1.uu'\"
  326. else
  327. echo shar: Extracting \"'gdostool1.uu'\" \(532 characters\)
  328. sed "s/^X//" >'gdostool1.uu' <<'END_OF_FILE'
  329. Xbegin 666 gdostool.info
  330. XMXQ```0`````!7@"9`",`$0`%``,``0#"W<``````````````````````````(
  331. XM`````\,`P%-P`````````4X```".``%ZX`````````^@````+@%R`)?__P``F
  332. XM```"0`)_``%=!```````P!*`````````````6@`H_____P`!____Z0``````<
  333. XM`````",`$``"``%\H`,```````!__\````!_X<````!_X<````!_X<````!_R
  334. XM_\````````````````````/ZJ/````/U1'@```/JHC@```/5<1@```.J__@`4
  335. XM``-5__@```*K__@```/___@``````````/____^``/_____``/_____@`/__^
  336. XM___@`/_____@`/_____@`/_____@`/P']0_@`/P.ZH?@`/P=U4?@`/P[BJ?@1
  337. XD`/QW``?@`/SN``?@`,W<``?@`/P```?@``````````````$`?
  338. X``
  339. Xend
  340. Xsize 351
  341. END_OF_FILE
  342. if test 532 -ne `wc -c <'gdostool1.uu'`; then
  343.     echo shar: \"'gdostool1.uu'\" unpacked with wrong size!
  344. fi
  345. # end of 'gdostool1.uu'
  346. fi
  347. echo shar: End of archive 1 \(of 1\).
  348. cp /dev/null ark1isdone
  349. MISSING=""
  350. for I in 1 ; do
  351.     if test ! -f ark${I}isdone ; then
  352.     MISSING="${MISSING} ${I}"
  353.     fi
  354. done
  355. if test "${MISSING}" = "" ; then
  356.     echo You have the archive.
  357.     rm -f ark[1-9]isdone
  358. else
  359.     echo You still need to unpack the following archives:
  360.     echo "        " ${MISSING}
  361. fi
  362. ##  End of shell archive.
  363. exit 0
  364. -- 
  365. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  366. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  367. Post requests for sources, and general discussion to comp.sys.amiga.
  368.